feat: image url support for image fields in local editor#1242
feat: image url support for image fields in local editor#1242briantstephan wants to merge 1 commit into
Conversation
|
Warning: Component files have been updated but no migrations have been added. See https://github.com/yext/visual-editor/blob/main/packages/visual-editor/src/components/migrations/README.md for more information. |
| return getPathname(locationLike).startsWith("/dev-"); | ||
| }; | ||
|
|
||
| export const isLocalEditorRoute = (locationLike: LocationLike) => { |
There was a problem hiding this comment.
Should we just update isFakeStarterLocalDev? If we want both, I'd make it a callable func without having to pass in variables like we do for isFakeStarterLocalDev. It's weird that that one handles window undefined and window.location but you make those calls manually in usages for this func.
WalkthroughThe change adds a new exported helper Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/visual-editor/src/fields/ImageField.test.tsx`:
- Around line 74-75: The window.prompt spy is mocked in the prompt-related tests
but not explicitly restored in the shared afterEach cleanup block, causing the
mock to leak into subsequent tests. In the afterEach block (where
window.history.replaceState is called), add an explicit restoration of the
window.prompt spy to ensure the mock is cleaned up after each test and prevent
test order dependencies.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9294f9cc-f8fe-41e9-8b60-db04af573c99
📒 Files selected for processing (5)
packages/visual-editor/src/components/contentBlocks/image/EmptyImageState.tsxpackages/visual-editor/src/fields/ImageField.test.tsxpackages/visual-editor/src/fields/ImageField.tsxpackages/visual-editor/src/utils/isFakeStarterLocalDev.test.tspackages/visual-editor/src/utils/isFakeStarterLocalDev.ts
| window.history.replaceState({}, "", initialUrl); | ||
| }); |
There was a problem hiding this comment.
Restore mocked spies in shared cleanup.
window.prompt is mocked in prompt tests but not explicitly restored in shared teardown, which can leak mocked behavior into later tests and create order-dependent failures.
Suggested fix
afterEach(() => {
+ vi.restoreAllMocks();
sendToParentMock.mockReset();
window.history.replaceState({}, "", initialUrl);
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| window.history.replaceState({}, "", initialUrl); | |
| }); | |
| afterEach(() => { | |
| vi.restoreAllMocks(); | |
| sendToParentMock.mockReset(); | |
| window.history.replaceState({}, "", initialUrl); | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/visual-editor/src/fields/ImageField.test.tsx` around lines 74 - 75,
The window.prompt spy is mocked in the prompt-related tests but not explicitly
restored in the shared afterEach cleanup block, causing the mock to leak into
subsequent tests. In the afterEach block (where window.history.replaceState is
called), add an explicit restoration of the window.prompt spy to ensure the mock
is cleaned up after each test and prevent test order dependencies.
This allows users of the local-editor to update image fields using a publicly-hosted image URL, like in the fake starter.
Demo:
Screen.Recording.2026-06-18.at.4.17.22.PM.mov